/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * GestionarCSC_UI.java
 *
 * Created on 9/06/2009, 04:24:08 PM
 */

package CRM_UI;

import DAO.DAOCasoServicioCliente;
import LogicaNegocio.CasoServicioCliente;
import java.util.Vector;
import javax.swing.JOptionPane;
import javax.swing.table.DefaultTableModel;

/**
 *
 * @author L¡z
 */
public class GestionarCSC_UI extends javax.swing.JFrame {

    /** Creates new form GestionarCSC_UI */
    Vector <Vector> cscTabla = new Vector<Vector>();
    Vector <String> nombresColumnas = new Vector<String>();
    String idSeleccionado;

    public GestionarCSC_UI() {
        inicializarTabla();
        consultarCSC();
        initComponents();
        setLocationRelativeTo(null);
        actualizarTabla();

    }

    public void inicializarTabla()
    {
        nombresColumnas.addElement("Identificador");
        nombresColumnas.addElement("Estado");
        nombresColumnas.addElement("Nivel Prioridad");
        nombresColumnas.addElement("Descripcion");
        nombresColumnas.addElement("Fecha Inicio");
        nombresColumnas.addElement("Fecah Finalizacion");
        nombresColumnas.addElement("Calificacion");
        nombresColumnas.addElement("Id Cliente");
        nombresColumnas.addElement("CC Empleado");
    }

    public void consultarCSC()
    {
        DAOCasoServicioCliente objDaoCSC = new DAOCasoServicioCliente();
        Vector <CasoServicioCliente> csc= objDaoCSC.consultarCasosServicioCliente();

        for(int i=0; i<csc.size(); i++)
        {
            Vector <String> elCSC = new Vector <String>();
            elCSC.addElement(csc.elementAt(i).getIdCasoSC());
            elCSC.addElement(csc.elementAt(i).getEstadoCasoSC());
            elCSC.addElement(csc.elementAt(i).getNivelPrioridadCasoSC());
            elCSC.addElement(csc.elementAt(i).getDescripcionCasoSC());
            elCSC.addElement(csc.elementAt(i).getFechaInicioCasoSC());
            elCSC.addElement(csc.elementAt(i).getFechaFinalizacionCasoSC());
            elCSC.addElement(csc.elementAt(i).getCalificacionCasoSC());
            elCSC.addElement(csc.elementAt(i).getIdCliente());
            elCSC.addElement(csc.elementAt(i).getCcEmpleado());
            cscTabla.addElement(elCSC);
        }

    }

    public void actualizarTabla()
    {
        jTable1.setModel(new DefaultTableModel (cscTabla, nombresColumnas));
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel1 = new javax.swing.JPanel();
        jScrollPane2 = new javax.swing.JScrollPane();
        jScrollPane1 = new javax.swing.JScrollPane();
        jTable1 = new javax.swing.JTable();
        jPanel2 = new javax.swing.JPanel();
        crearButton = new javax.swing.JButton();
        idLabel = new javax.swing.JLabel();
        descripcionLabel = new javax.swing.JLabel();
        tipoLabel = new javax.swing.JLabel();
        prioridadLabel = new javax.swing.JLabel();
        idTextField = new javax.swing.JTextField();
        fechaInicioLabel = new javax.swing.JLabel();
        fechaFinalizacionLabel = new javax.swing.JLabel();
        jLabel7 = new javax.swing.JLabel();
        diaInicioCb = new javax.swing.JComboBox();
        mesInicioCb = new javax.swing.JComboBox();
        aNoInicioCb = new javax.swing.JComboBox();
        modificarButton = new javax.swing.JButton();
        jScrollPane3 = new javax.swing.JScrollPane();
        descripcionTextArea = new javax.swing.JTextArea();
        diaFinCb = new javax.swing.JComboBox();
        mesFinCb = new javax.swing.JComboBox();
        aNoFinCb = new javax.swing.JComboBox();
        prioridadComboBox = new javax.swing.JComboBox();
        calificaciónComboBox = new javax.swing.JComboBox();
        tipoComboBox = new javax.swing.JComboBox();
        estadoLabel = new javax.swing.JLabel();
        estadoComboBox = new javax.swing.JComboBox();
        eliminarButton = new javax.swing.JButton();
        jLabel9 = new javax.swing.JLabel();
        jLabel1 = new javax.swing.JLabel();
        clienteTextField = new javax.swing.JTextField();
        jLabel2 = new javax.swing.JLabel();
        empleadoTextField = new javax.swing.JTextField();

        jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder("CSC"));

        /*
        jTable1.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null}
            },
            new String [] {
                "Identificador", "Descripción", "Estado", "Tipo", "Nivel", "Fecha Inicio", "Fecha Finalización", "Calificación"
            }
        ) {
            boolean[] canEdit = new boolean [] {
                false, false, false, false, false, false, false, false
            };

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        */
        jTable1.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jTable1MouseClicked(evt);
            }
        });
        jScrollPane1.setViewportView(jTable1);

        jScrollPane2.setViewportView(jScrollPane1);

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGap(19, 19, 19)
                .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 469, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(46, Short.MAX_VALUE))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder("Modificar"));

        crearButton.setText("crear");
        crearButton.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                crearButtonMouseClicked(evt);
            }
        });
        crearButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                crearButtonActionPerformed(evt);
            }
        });

        idLabel.setText("Identificador:");

        descripcionLabel.setText("Descripción:");

        tipoLabel.setText("Tipo:");

        prioridadLabel.setText("Nivel de Prioridad:");

        idTextField.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                idTextFieldActionPerformed(evt);
            }
        });

        fechaInicioLabel.setText("Fecha de Inicio:");

        fechaFinalizacionLabel.setText("Fecha de Finalización:");

        jLabel7.setText("Calificación:");

        diaInicioCb.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "30", "31" }));

        mesInicioCb.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Enero", "Febrero", "Marzo", "Abril", "Mayo", "Junio", "Julio", "Agosto", "Septiembre", "Octubre", "Noviembre", "Diciembre" }));

        aNoInicioCb.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "1980", "1981", "1982", "1983", "1984", "1985", "1986", "1987", "1988", "1989", "1990", "1991", "1992", "1993", "1994", "1995", "1996", "1997", "1998", "1999", "2000", "2001", "2002", "2003", "2004", "2005", "2006", "2007", "2008", "2009" }));
        aNoInicioCb.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                aNoInicioCbActionPerformed(evt);
            }
        });

        modificarButton.setText("modificar");
        modificarButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                modificarButtonActionPerformed(evt);
            }
        });

        descripcionTextArea.setColumns(20);
        descripcionTextArea.setRows(5);
        jScrollPane3.setViewportView(descripcionTextArea);

        diaFinCb.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "30", "31" }));

        mesFinCb.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Enero", "Febrero", "Marzo", "Abril", "Mayo", "Junio", "Julio", "Agosto", "Septiembre", "Octubre", "Noviembre", "Diciembre" }));

        aNoFinCb.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "1980", "1981", "1982", "1983", "1984", "1985", "1986", "1987", "1988", "1989", "1990", "1991", "1992", "1993", "1994", "1995", "1996", "1997", "1998", "1999", "2000", "2001", "2002", "2003", "2004", "2005", "2006", "2007", "2008", "2009" }));
        aNoFinCb.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                aNoFinCbActionPerformed(evt);
            }
        });

        prioridadComboBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Baja", "Normal ", "Alta" }));

        calificaciónComboBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Excelente", "Buena", "Regular", "Mala" }));

        tipoComboBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Quejas y Reclamos", "Consulta de Pedidos y/o Servicios Adquiridos", "Oportunidades de Negocio", "Cancelacion de Servicios" }));
        tipoComboBox.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                tipoComboBoxMouseClicked(evt);
            }
        });
        tipoComboBox.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                tipoComboBoxActionPerformed(evt);
            }
        });

        estadoLabel.setText("Estado:");

        estadoComboBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Iniciado", "En Proceso", "Resuelto", "No Resuelto" }));

        eliminarButton.setText("eliminar");
        eliminarButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                eliminarButtonActionPerformed(evt);
            }
        });

        jLabel9.setText("Codigo Cliente:");

        jLabel1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/resources/home.png"))); // NOI18N

        jLabel2.setText("CC Empleado:");

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(idLabel)
                    .addComponent(descripcionLabel)
                    .addComponent(estadoLabel)
                    .addComponent(tipoLabel)
                    .addComponent(prioridadLabel)
                    .addComponent(fechaInicioLabel)
                    .addComponent(fechaFinalizacionLabel)
                    .addComponent(jLabel7)
                    .addComponent(jLabel9)
                    .addComponent(jLabel2))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(estadoComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jScrollPane3, javax.swing.GroupLayout.DEFAULT_SIZE, 287, Short.MAX_VALUE)
                    .addComponent(idTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 71, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(prioridadComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addComponent(diaInicioCb, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(mesInicioCb, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(aNoInicioCb, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(102, 102, 102))
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addComponent(diaFinCb, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(mesFinCb, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(aNoFinCb, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(clienteTextField, javax.swing.GroupLayout.DEFAULT_SIZE, 287, Short.MAX_VALUE)
                    .addComponent(calificaciónComboBox, 0, 287, Short.MAX_VALUE)
                    .addComponent(empleadoTextField, javax.swing.GroupLayout.DEFAULT_SIZE, 287, Short.MAX_VALUE)
                    .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                        .addGroup(jPanel2Layout.createSequentialGroup()
                            .addComponent(crearButton)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                            .addComponent(modificarButton)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addComponent(eliminarButton))
                        .addComponent(tipoComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addGap(132, 132, 132)
                .addComponent(jLabel1))
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(idLabel)
                            .addComponent(idTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel2Layout.createSequentialGroup()
                                .addGap(21, 21, 21)
                                .addComponent(descripcionLabel))
                            .addGroup(jPanel2Layout.createSequentialGroup()
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addComponent(jScrollPane3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(estadoComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(estadoLabel))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(tipoComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(tipoLabel))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(prioridadComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(prioridadLabel))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(diaInicioCb, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(fechaInicioLabel)
                            .addComponent(mesInicioCb, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(aNoInicioCb, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(diaFinCb, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(fechaFinalizacionLabel)
                            .addComponent(mesFinCb, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(aNoFinCb, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(calificaciónComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel7))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel9)
                            .addComponent(clienteTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel2)
                            .addComponent(empleadoTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 41, Short.MAX_VALUE)
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(modificarButton)
                            .addComponent(eliminarButton)
                            .addComponent(crearButton))
                        .addContainerGap())
                    .addComponent(jLabel1, javax.swing.GroupLayout.Alignment.TRAILING)))
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jPanel2, javax.swing.GroupLayout.Alignment.LEADING, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jPanel1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void eliminarButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_eliminarButtonActionPerformed
        // TODO add your handling code here:
        DAOCasoServicioCliente objDaoCSC = new DAOCasoServicioCliente();
        int result = objDaoCSC.eliminarCSC(idSeleccionado);

        if(result == -1)
        {
            JOptionPane.showMessageDialog(null, "No se pudo eliminar \n el Caso de Servicio al Cliente", "Error al Eliminar", JOptionPane.ERROR_MESSAGE);
        }
        else
        {
            JOptionPane.showMessageDialog(null, "Caso de Servicio al Cliente eliminado con éxito", "Operación Exitosa", JOptionPane.ERROR_MESSAGE);
        }

        consultarCSC();
        actualizarTabla();
}//GEN-LAST:event_eliminarButtonActionPerformed

    private void crearButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_crearButtonActionPerformed
        // TODO add your handling code here:

                /*Si → el caso es una Oportunidad de negocio →
         se asigna automáticameente al 	Depto.De Ventas y estado= resuelto
        -Cuando el estado del caso=resuelto el Cliente puede calificar el caso
        */
        String aNoInicio = aNoInicioCb.getSelectedItem().toString();
        String aNoFin = aNoFinCb.getSelectedItem().toString();
        String fechaInicio = "";
        String fechaFin = "";

        if(mesInicioCb.getSelectedIndex() <= 9)
        {
            fechaInicio = (diaInicioCb.getSelectedIndex()+1)+"-"+"0"
                          +(mesInicioCb.getSelectedIndex() + 1)+"-"+aNoInicio;
        }
        else
        {
            fechaInicio = (diaInicioCb.getSelectedIndex() +1)+"-"+
                          +(mesInicioCb.getSelectedIndex() + 1)+"-"+aNoInicio;
        }

        if(mesFinCb.getSelectedIndex() <= 9)
        {
            fechaFin = (diaFinCb.getSelectedIndex()+1)+"-"+"0"
                          +(mesFinCb.getSelectedIndex()+1)+"-"+aNoInicio;
        }
        else
        {
            fechaFin = (diaFinCb.getSelectedIndex() + 1)+"-"+
                          +(mesFinCb.getSelectedIndex() + 1)+"-"+aNoInicio;
        }

        System.out.println(fechaInicio);
        System.out.println(fechaFin);

        if(tipoComboBox.getSelectedItem().toString().equals("Oportunidad de Negocio"))
        {
            estadoComboBox.setSelectedItem("Resuelto");
        }

        DAOCasoServicioCliente objDaoCSC = new DAOCasoServicioCliente();
        CasoServicioCliente csc = new CasoServicioCliente(idTextField.getText(), estadoComboBox.getSelectedItem().toString(),prioridadComboBox.getSelectedItem().toString(),
                                                          tipoComboBox.getSelectedItem().toString(), descripcionTextArea.getText(),fechaInicio,fechaFin,
                                                           calificaciónComboBox.getSelectedItem().toString(), clienteTextField.getText(), empleadoTextField.getText());

        objDaoCSC.guardarCasoServicioCliente(csc);

        consultarCSC();
        actualizarTabla();
}//GEN-LAST:event_crearButtonActionPerformed

    private void idTextFieldActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_idTextFieldActionPerformed
        // TODO add your handling code here:
}//GEN-LAST:event_idTextFieldActionPerformed

    private void modificarButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_modificarButtonActionPerformed
        // TODO add your handling code here:
        String aNoInicio = aNoInicioCb.getSelectedItem().toString();
        String aNoFin = aNoFinCb.getSelectedItem().toString();
        String fechaInicio = "";
        String fechaFin = "";

        if(mesInicioCb.getSelectedIndex() <= 9)
        {
            fechaInicio = (diaInicioCb.getSelectedIndex() + 1)+"-"+"0"
                          +(mesInicioCb.getSelectedIndex() +1)+"-"+aNoInicio;
        }
        else
        {
            fechaInicio = (diaInicioCb.getSelectedIndex() + 1)+"-"+
                          +(mesInicioCb.getSelectedIndex() + 1)+"-"+aNoInicio;
        }

        if(mesFinCb.getSelectedIndex() <= 9)
        {
            fechaFin = (diaFinCb.getSelectedIndex()+ 1)+"-"+"0"
                          +(mesFinCb.getSelectedIndex() + 1)+"-"+aNoInicio;
        }
        else
        {
            fechaFin = (diaFinCb.getSelectedIndex()+ 1)+"-"+
                          +(mesFinCb.getSelectedIndex() + 1)+"-"+aNoInicio;
        }

        System.out.println(fechaInicio);
        System.out.println(fechaFin);

        if(tipoComboBox.getSelectedItem().toString().equals("Oportunidad de Negocio"))
        {
            estadoComboBox.setSelectedItem("Resuelto");
        }

        DAOCasoServicioCliente objDaoCSC = new DAOCasoServicioCliente();
        CasoServicioCliente csc = new CasoServicioCliente(idTextField.getText(), estadoComboBox.getSelectedItem().toString(),prioridadComboBox.getSelectedItem().toString(),
                                                          tipoComboBox.getSelectedItem().toString(), descripcionTextArea.getText(),fechaInicio,fechaFin,
                                                           calificaciónComboBox.getSelectedItem().toString(), clienteTextField.getText(), empleadoTextField.getText());

        objDaoCSC.modificarCalificacionCSC(csc);
        objDaoCSC.modificarClienteCSC(csc);
        objDaoCSC.modificarDescripcionCSC(csc);
        objDaoCSC.modificarEmpleadoCSC(csc);
        objDaoCSC.modificarEstadoCSC(csc);
        objDaoCSC.modificarFechaFinalizacionCSC(csc);
        objDaoCSC.modificarFechaInicioCSC(csc);
        objDaoCSC.modificarNivelPrioridadCSC(csc);
        objDaoCSC.modificarTipoCSC(csc);

        consultarCSC();
        actualizarTabla();

}//GEN-LAST:event_modificarButtonActionPerformed

    private void aNoInicioCbActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_aNoInicioCbActionPerformed
        // TODO add your handling code here:
}//GEN-LAST:event_aNoInicioCbActionPerformed

    private void aNoFinCbActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_aNoFinCbActionPerformed
        // TODO add your handling code here:
}//GEN-LAST:event_aNoFinCbActionPerformed

    private void tipoComboBoxMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_tipoComboBoxMouseClicked
        // TODO add your handling code here:
}//GEN-LAST:event_tipoComboBoxMouseClicked

    private void tipoComboBoxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_tipoComboBoxActionPerformed
        // TODO add your handling code here:
}//GEN-LAST:event_tipoComboBoxActionPerformed

    private void crearButtonMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_crearButtonMouseClicked
        // TODO add your handling code here:

    }//GEN-LAST:event_crearButtonMouseClicked

    private void jTable1MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jTable1MouseClicked
        // TODO add your handling code here:
        int fila = jTable1.getSelectedRow();
        idSeleccionado = cscTabla.elementAt(fila).elementAt(0).toString();

        idTextField.setText(idSeleccionado);
        descripcionTextArea.setText(cscTabla.elementAt(fila).elementAt(1).toString());
        estadoComboBox.setSelectedItem(cscTabla.elementAt(fila).elementAt(2).toString());
        tipoComboBox.setSelectedItem(cscTabla.elementAt(fila).elementAt(3).toString());
        prioridadComboBox.setSelectedItem(cscTabla.elementAt(fila).elementAt(4).toString());
        calificaciónComboBox.setSelectedItem(cscTabla.elementAt(fila).elementAt(6).toString());
        clienteTextField.setText(cscTabla.elementAt(fila).elementAt(7).toString());
        empleadoTextField.setText(cscTabla.elementAt(fila).elementAt(8).toString());
    }//GEN-LAST:event_jTable1MouseClicked

    /**
    * @param args the command line arguments
    */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new GestionarCSC_UI().setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JComboBox aNoFinCb;
    private javax.swing.JComboBox aNoInicioCb;
    private javax.swing.JComboBox calificaciónComboBox;
    private javax.swing.JTextField clienteTextField;
    private javax.swing.JButton crearButton;
    private javax.swing.JLabel descripcionLabel;
    private javax.swing.JTextArea descripcionTextArea;
    private javax.swing.JComboBox diaFinCb;
    private javax.swing.JComboBox diaInicioCb;
    private javax.swing.JButton eliminarButton;
    private javax.swing.JTextField empleadoTextField;
    private javax.swing.JComboBox estadoComboBox;
    private javax.swing.JLabel estadoLabel;
    private javax.swing.JLabel fechaFinalizacionLabel;
    private javax.swing.JLabel fechaInicioLabel;
    private javax.swing.JLabel idLabel;
    private javax.swing.JTextField idTextField;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JScrollPane jScrollPane3;
    private javax.swing.JTable jTable1;
    private javax.swing.JComboBox mesFinCb;
    private javax.swing.JComboBox mesInicioCb;
    private javax.swing.JButton modificarButton;
    private javax.swing.JComboBox prioridadComboBox;
    private javax.swing.JLabel prioridadLabel;
    private javax.swing.JComboBox tipoComboBox;
    private javax.swing.JLabel tipoLabel;
    // End of variables declaration//GEN-END:variables

}
